<?php

Yii::import('application.models._base.BaseCategoryCategoryRelations');


class CategoryCategoryRelations extends BaseCategoryCategoryRelations
{
	public static function model($className=__CLASS__) {
		return parent::model($className);
	}

	public function relations(){
	    return array(
	        'category' =>  array(self::BELONGS_TO,'Category','category_id'  ),
	    );
	}
	public function getAllCategory($id){
		$category=array();
		$son=$this->findALL('parent_category_id = '.$id);
		if($son){
			foreach ($son as $kson => $vson) {
				$sunzi = $this->getAllCategory($vson->category_id);
				foreach ($sunzi as $keysunzi => $valuesunzi) {
					$category[] = $valuesunzi;
				}
			}
		}
		$category[] = $id;
		return $category;	
	}
		
}